//
//  RootViewController.m
//  UITabBarController
//
//  Created by Chuanxi.Chen on 15/9/7.
//  Copyright (c) 2015年 qianfeng. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    // Do any additional setup after loading the view.
    self.KSize = [UIScreen mainScreen].bounds.size;
}

-(void)createLeftButton:(NSString *)imageName andWith:(NSString *)tword{
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(onLeftButtonClick:)];
    if ([tword isEqualToString:@"left"]) {
        self.navigationItem.leftBarButtonItem = item;
        item.tag = -1;
    }else{
        self.navigationItem.rightBarButtonItem = item;
        item.tag = -2;
    }
}

-(void)onLeftButtonClick:(UIBarButtonItem *)item{
//    子类重写
    if (-1 == item.tag) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"返回成功" message:@"你按确定，我就消失" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }else{
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"没有信息" message:@"请按确定，耐心等待好友的偏爱" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];

    }
}


-(void)createTitle:(NSString *)title{
    UILabel *label = [[UILabel alloc]init];
    label.frame = CGRectMake(100, 0, self.KSize.width-200, 64);
    label.text = title;
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont boldSystemFontOfSize:20];
    self.navigationItem.titleView = label;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
